<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>导航栏</title>
  <script src="https://cdn.bootcdn.net/ajax/libs/vue/3.2.47/vue.global.js"></script>
  <style>
    body {
      width: 1000px;

    }

    * {
      margin: 0;
      padding: 0;
    }

    a {
      text-decoration: none;
      display: block;
      color: #fff;
      width: 120px;
      height: 40px;
      line-height: 40px;
      border: 1px solid #fff;
      border-width: #8b6247;

    }

    li {
      list-style-type: none;
    }

    #app {
      height: 40px;
      width: 1000px;
      background-color: #d42038;

    }

    ul {
      padding-inline-start: 0px;
    }

    #app>li {

      list-style: none;
      float: left;
      text-align: center;
      position: relative;
    }

    .tou img {
      width: 1000px;

    }


    #app li a:hover {
      color: #fff;
      background-image: url(./img/11.png);
    }

    #app li ul {
      position: absolute;

      top: 40px;
      width: 120px;
      margin-top: 1px;
      font-size: 12px;
      background-color: #d42038;
    }

    [v-cloak] {
      display: none;
    }
  </style>
</head>

<body>
  <div class="tou">
    <img src="./img/tou.jpg" alt="">
  </div>
  <div id="app" v-cloak>
    <li v-for="menu in menus" @mouseover="menu.show = !menu.show" @mouseout="menu.show = !menu.show">
      <!-- 一级菜单 -->
      <a :href="menu.url">
        {{menu.name}}
      </a>
      <!-- 二级菜单 -->
      <ul v-show="menu.show">
        <li v-for="subMenu in menu.subMenus">
          <a :href="subMenu.url">
            {{subMenu.name}}
          </a>
        </li>
      </ul>
    </li>
  </div>
  <script>
    const data = {
      menus: [
        {
          // 一级菜单
          name: '关于红岩', url: '#', show: false, subMenus: [
            // 二级菜单
            { name: 'Python 课程', url: '#' },
            { name: 'Java课程', url: '#' },
            { name: '前端课程', url: '#' }
          ]
        },
        {
          // 一级菜单
          name: '公告动态', url: '#', show: false, subMenus:
            [
              // 二级菜单
              { name: 'Python 课程', url: '#' },
              { name: 'Java课程', url: '#' },
              { name: '前端课程', url: '#' }
            ]
        },
        {
          // 一级菜单
          name: '馆藏精品', url: '#', show: false, subMenus:
            [
              // 二级菜单
              { name: '团队介绍', url: '#' },
              { name: '联系我们', url: '#' },
            ]
        },
        {
          // 一级菜单
          name: '陈列展览', url: '#', show: false, subMenus:
            [
              // 二级菜单
              { name: '团队介绍', url: '#' },
              { name: '联系我们', url: '#' },
            ]
        },
        {
          // 一级菜单
          name: '研究开发', url: '#', show: false, subMenus:
            [
              // 二级菜单
              { name: '团队介绍', url: '#' },
              { name: '联系我们', url: '#' },
            ]
        },
        {
          // 一级菜单
          name: '公共教育', url: '#', show: false, subMenus:
            [
              // 二级菜单
              { name: '团队介绍', url: '#' },
              { name: '联系我们', url: '#' },
            ]
        },
        {
          // 一级菜单
          name: '参观服务品', url: '#', show: false, subMenus:
            [
              // 二级菜单
              { name: '团队介绍', url: '#' },
              { name: '联系我们', url: '#' },
            ]
        },
        {
          // 一级菜单
          name: '网上预约', url: '#', show: false, subMenus:
            [
              // 二级菜单
              { name: '团队介绍', url: '#' },
              { name: '联系我们', url: '#' },
            ]
        },
      ]
    }
    const vm = Vue.createApp({
      data () {
        return data;
      }
    }).mount('#app');
  </script>
</body>

</html>